<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
<title>코오롱</title>
<link rel="stylesheet" type="text/css" href="${requestScope.contextPath}/css/import.css" />
<script type="text/javascript" src="${requestScope.contextPath}/js/jquery-ui-1.8.14.custom/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="${requestScope.contextPath}/js/jquery-ui-1.8.14.custom/js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="${requestScope.contextPath}/js/common.js"></script>
<c:set var="userAgent" value="${header['User-Agent']}" />
<fmt:setBundle basename="com.kolon.config.properties.config" var="config" />
<c:if test="${fn:indexOf(userAgent, 'Android') != -1}"><c:set var="platForm" value="Android" /></c:if>
<c:if test="${fn:indexOf(userAgent, 'iPhone') != -1}"><c:set var="platForm" value="iPhone" /></c:if>
<script type="text/javascript">
	function appBack() {
		document.location.href='${requestScope.contextPath}/business/mOI_/mOIJudgeList.do?pageGubun=A&page=${param.page}&endY=${param.endY}';
	}
</script>
<link rel="stylesheet" type="text/css" href="${requestScope.contextPath}/js/jquery-ui-1.8.14.custom/css/ui-lightness/jquery-ui-1.8.14.custom.css" />
<script type="text/javascript">
	var cpyCD = '${sessionScope.SESSION_USER_INFO.CompanyCD}';
	var sugflag = '${param.sugflag}';
	var toDay = '${toDay}';
	function formCheck() {
		val = $('#JudgeName').val();
		valStr = $('#JudgeName option:selected').text();
		if (val == '' || val == undefined) {
			alert('심사을 선택해 주세요.');
			return;
		}
		if ((cpyCD == 'KEC' || cpyCD == 'KNC') && (val == '0' || val == '1')) {
			if (!execCheck()) return;
		} else if (val == '0'){
			if (!execCheck()) return;
		} else if (valStr == '자동실천' && sugflag != 'pubSubj') {
			if (!execCheck()) return;
		}
		/*
		if ((cpyCD == 'KEC' || cpyCD == 'KNC') && (val == '0' || val == '1')) {
			if (!execCheck()) return;
		} else if (val == '3' && valStr != '내용보완') {
			if (!execCheck()) return;
		} else if (val == '0'){
			if (!execCheck()) return;
		}
		if($('#txtJudgeOpinion').val() == '') {
			alert('심사의견을 입력해 주세요.');
			return;
		}
		*/
		if (confirm('확정하시겠습니까?')) {
			document.judgeForm.submit();
		}
	}
	function execCheck() {
		if ($('#txtStartDate').val() == '' || $('#execId').val() == '' || $('#execName').val() == '') {
			alert('실시자 및 실시완료일을 입력해 주세요');
			return false;
		}
		if ($('#txtStartDate').val() < toDay) {
			
			alert('실시완료일은 오늘이후만 선택해 주세요.');
			return false;
		}
		return true;
	}
	function judgeExecSch(execNm) {
		if (execNm == '' || execNm == undefined) {
			$.ajax({
				url: '${requestScope.contextPath}/business/mOI_/mOIJudgeExecSch.do',
				type:'POST',
				dataType:'html',
				success: function(html){
					$('#judgeExecSch').html(html);
					$('#wrap').hide();
					$('#judgeExecSch').show();
				},
				error: function(){
					alert('error');
				}
			});
		} else {
			$.ajax({
				url: '${requestScope.contextPath}/business/mOI_/mOIJudgeExecSch.do',
				type:'POST',
				data: {
					'execNm': execNm
				},
				dataType:'json',
				success: function(json){
					$('#execNmList').html('');
					if(json) {
						if (json.list.length == 0) {
							$('#execNmList').append('<li>검색된 이름이 없습니다.</li>');
						} else {
							for( i = 0 ; i < json.list.length; i++ ){
								$('#execNmList').append('<li><a href="javascript:execChoice(\''+json.list[i].UserName+'\', \''+json.list[i].UserAccount+'\');">['+json.list[i].DeptName+'] '+json.list[i].TitleName+' '+json.list[i].UserName+'</a></li>');
							}
						}
					}
				},
				error: function(){
					alert('error');
				}
			});
		}
	}
	function execChoice(execName, execId) {
		$('#execId').val(execId);
		$('#execName').val(execName);
		$('#judgeExecSch').hide();
		$('#wrap').show();
	}
	function closeJudgeExec() {
		$('#wrap').show();
		$('#judgeExecSch').hide();
	}
	function judgeOnchange(obj) {
		val = obj.value;
		valStr = $('#JudgeName option:selected').text();
		$('#jmID').val(valStr);
		if ((cpyCD == 'KEC' || cpyCD == 'KNC') && (val == '0' || val == '1')) {
			$('#execTr_1').show();
			$('#execTr_2').show();
		} else if (valStr == '자동실천' && sugflag != 'pubSubj') {
			$('#execTr_1').show();
			$('#execTr_2').show();
		} else if (val == '0'){
			$('#execTr_1').show();
			$('#execTr_2').show();
		} else {
			$('#execTr_1').hide();
			$('#execTr_2').hide();
			$('#execId').val('');
			$('#execName').val('');
			$('#txtStartDate').val('');
		}
	}
	$().ready(function() {
		$('#txtStartDate').datepicker({
			 changeMonth: false
			,selectOtherMonths: true
			,showOtherMonths: true
			,changeYear: false
			,showOn: 'button'
			,showAnim: 'slideDown'
			,showMonthAfterYear:true
			,buttonImage: '${requestScope.contextPath}/images/reservation/cal1.gif'
			,buttonImageOnly: true
			,dateFormat: 'yy-mm-dd'
			,monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
			,dayNamesMin: ['일', '월', '화', '수', '목', '금', '토']
			,showButtonPanel: true
		});
	});
</script>
<script>
$(document).ready(function(){ 
	$('#viewPage_').find('img').each(function() {
		w = $(this).attr('width');
		h = $(this).attr('height');
		if (w > 230 || w == undefined) {
			imgUrl = "location.href='${requestScope.contextPath}/imgZoom.jsp?imgUrl=" + $(this).attr('src')+"&width="+$(this).attr('width')+"&height="+$(this).attr('height')+"'";
			$(this).attr('width', '230');
			$(this).attr('height', Math.round(h*(230/w)));
			$(this).attr('onClick', imgUrl);
		}
	});
});
</script>
<style>
.ui-datepicker-close, .ui-datepicker-current { height:30px !important;}
</style>
</head>
<body>
	<div id="wrap">
		<div class="header">
			<h1>O.I. 제안</h1>
		</div><!-- // header -->
		<div class="content">
			<h3>아이디어 제안</h3>
			<div class="access">
			<div class="table5">
			<form name="judgeForm" action="${requestScope.contextPath}/business/mOI_/mOIIdeaJudgeWrite.do" method="post" onsubmit="return false;">
			<input type="hidden" name="seq" value="${param.seq}" />
			<input type="hidden" name="page" value="${param.page}" />
			<input type="hidden" name="pageGubun" value="${param.pageGubun}" />
			<input type="hidden" name="endY" value="${param.endY}" />
			<input type="hidden" name="deptNum" value="${map.DEPTNUM}" />
				<table summary="" cellspacing="0" style="width:100%;">
					<caption>아이디어 제안</caption>
					<colgroup>
						<col style="width:25%" />
						<col style="width:75%" />
						</colgroup>
					<tbody>
						<tr>
							<th scope="row"><label for="name">제안자</label></th>
							<td>
								<c:choose>
								<c:when test="${map.Unsigned eq 'Y'}">무기명</c:when>
								<c:otherwise>${map.EmpName} ${map.DeptName} (${map.TelNum})</c:otherwise>
								</c:choose>
							</td>
						</tr>
						<tr>
							<th scope="row">제안일자</th>
							<td>${map.CreateDate}&nbsp;</td>
						</tr>
						<tr>
							<th scope="row"><label for="title">제목</label></th>
							<td>${map.Title}&nbsp;</td>
						</tr>
						<tr>
							<th scope="row"><label for="coment">내용</label></th>
							<td><div id="viewPage_">${map.Content}</div>&nbsp;</td>
						</tr>
						<c:if test="${map.DEPTNUM > 1}">
						<tr>
							<th scope="row">심사부서 변경</th>
							<td>${map.judgeDept}&nbsp;</td>
						</tr>
						</c:if>
						<tr>
							<th scope="row">심사</th>
							<td>
								<input type="hidden" id="jmID" name="JudgeName" size="5" />
								<select id="JudgeName" style="width:50%;" onchange="judgeOnchange(this);">
									<option value="">심사 선택</option>
								<c:forEach var="gbMap" items="${gbList}" varStatus="state">
									<option value="${state.index}">${gbMap.SUB1}</option>
								</c:forEach>
								</select>
							</td>
						</tr>
						<tr>
							<th scope="row">심사자</th>
							<td>
								${sessionScope.SESSION_USER_INFO.UserName}
							</td>
						</tr>
						<tr>
							<th scope="row">검색공개</th>
							<td>
								<select name="SearchAuth" style="width:50%;">
									<option value="1">그룹공개</option>
									<option value="2">소속사공개</option>
									<option value="3">보안</option>
								</select>
							</td>
						</tr>
						<tr id="execTr_1" style="display: none;">
							<th scope="row">실시자</th>
							<td>
								<input type="text" id="execName" name="execName" class="intxt5" size="5" readonly="readonly" onclick="judgeExecSch();" />
								<input type="hidden" id="execId" name="execId" class="intxt5" /> <a href="javascript:judgeExecSch();"><img src="${requestScope.contextPath}/images/btn/btn_search2.gif" alt="검색" /></a>
							</td>
						</tr>
						<tr id="execTr_2" style="display: none;">
							<th scope="row">실시완료일</th>
							<td>
								<input type="text" id="txtStartDate" name="txtStartDate" class="intxt5" />
							</td>
						</tr>
						<tr>
							<th scope="row"><label for="txtJudgeOpinion">심사의견</label></th>
							<td><textarea cols="30" name="txtJudgeOpinion" rows="3" id="txtJudgeOpinion" class="comment"></textarea></td>
						</tr>
					</tbody>
				</table>
				</form>
				<p class="btn_more" style="padding-bottom:20px;">
					<a href="#" onclick="formCheck();"><img src="${requestScope.contextPath}/images/oi/btn_confirm.gif" alt="심사확정" /></a>&nbsp;&nbsp;
					<a href="${requestScope.contextPath}/business/mOI_/mOIJudgeList.do?pageGubun=${param.pageGubun}&page=${page}&endY=${param.endY}"><img src="${requestScope.contextPath}/images/btn/btn_view2.gif" alt="목록보기" /></a></p>
			</div>
			</div>
		</div><!-- // content -->
	</div><!-- // wrap -->
	<div id="judgeExecSch" style="display: none;"></div>
</body>
</html>
